//
//  MYGCaseFilesTableViewCell.swift
//  MYGrow
//
//  Created by 王振明 on 2024/3/16.
//

import UIKit

class MYGCaseFilesTableViewCell: UITableViewCell {
    
    
    var data:[String:String]? {
        didSet {
            guard let model = data else {
                return
            }
            
            titleLabel.text = model["name"]
            let i = model["type"]
            if i == "1" {
                leftLineView.backgroundColor = .rgba(255, 191, 150, 1)
            }else if (i == "2"){
                leftLineView.backgroundColor = .rgba(138, 178, 255, 1)
            }
            else if (i == "3"){
                leftLineView.backgroundColor = .rgba(255, 120, 120, 1)
            }
            else if (i == "4"){
                leftLineView.backgroundColor = .rgba(255, 135, 249, 1)
            }else {
                leftLineView.backgroundColor = .rgba(255, 153, 87, 1)
            }
            
        }
        
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        initUI()
    }
    func initUI(){
        self.backgroundColor = .clear
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(16))
            make.top.equalToSuperview().offset(SCALEWIDTH(10))
            make.height.equalTo(SCALEWIDTH(22.5))
        }
        contentView.addSubview(leftLineView)
        leftLineView.snp.makeConstraints { make in
            make.left.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(73))
            make.width.equalTo(SCALEWIDTH(4))
        }
        contentView.addSubview(headerImageView)
        headerImageView.snp.makeConstraints { make in
            make.right.equalToSuperview().offset(SCALEWIDTH(-16))
            make.centerY.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(80))
            make.width.equalTo(SCALEWIDTH(111))
        }
        
        contentView.addSubview(contentLabel)
        contentLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().offset(SCALEWIDTH(16))
            make.top.equalTo(titleLabel.snp.bottom).offset(SCALEWIDTH(8))
            make.height.equalTo(SCALEWIDTH(37))
            make.right.equalTo(headerImageView.snp.left).offset(-SCALEWIDTH(10.5))
        }
        contentView.addSubview(bottomLineView)
        bottomLineView.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(SCALEWIDTH(0.5))
        }
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var headerImageView:UIImageView = {
        let cont = UIImageView()
        cont.contentMode = .scaleAspectFill
        cont.image = UIImage(named: "Project/normal")
        return cont
    }()
    lazy var leftLineView:UIView = {
        let cont = UIView()
        cont.backgroundColor = .rgba(138, 178, 255)
        return cont
    }()
    lazy var bottomLineView:UIView = {
        let cont = UIView()
        cont.backgroundColor = .rgba(216, 216, 216,0.5)
        return cont
    }()
    private lazy var titleLabel:UILabel = {
       let cont = UILabel()
        cont.font = .medium(16)
        cont.textColor = .rgba(0, 0, 0,1)
        cont.text = "病历夹名称"
        return cont
    }()
    private lazy var contentLabel:UILabel = {
       let cont = UILabel()
        cont.font = .regular(13)
        cont.textColor = .rgba(124, 124, 124,1)
        cont.text = "诊断：心脑血管疾病心脑血管疾病心脑血管疾病"
        cont.numberOfLines = 2
        return cont
    }()
}
